﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Clothes.Masters.Forms;
using Clothes.Masters.ModuleData;

namespace Clothes.Items.Forms
{
    public partial class ImportDesigner : ApplicationLibrary.DBManager.BatchForm
    {
        DRDesctiptionTypeByDesc dRDesctiptionTypeByDesc;
        public ImportDesigner()
        {
            InitializeComponent();
        }

        private void btnDesigner_Click(object sender, EventArgs e)
        {
            if (ofdDesigner.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                txtFile.Text = ofdDesigner.FileName;
        }


        protected override void OnAttachData()
        {
            dRDesctiptionTypeByDesc = new DRDesctiptionTypeByDesc(DescriptionType.E_Designer);
        }
        protected override void OnBatchExecute()
        {
            string line;
            Descriptions descriptions = new Descriptions(DescriptionType.E_Designer, "");
            descriptions.ShowDialog(false);


            System.IO.StreamReader file = new System.IO.StreamReader(txtFile.Text);
            while ((line = file.ReadLine()) != null)
            {
                if (!dRDesctiptionTypeByDesc.Find(line))
                {
                    string p = line.Substring(0,1);
                    if (line.Substring(0, 1).CompareTo("0") >= 0  && descriptions.AddNew())
                        descriptions.txtBox.Text = line;

                    descriptions.Save();
                }
            }

            file.Close();
            descriptions.Close();
        }
    }
}
